
<%@ page import="activity.Event" %>
<!DOCTYPE html>
<html>
    <head>
        <meta name="layout" content="backend">
        <g:set var="entityName" value="${message(code: 'event.label', default: 'Event')}" />
        <title><g:message code="default.list.label" args="[entityName]" /></title>
    </head>
    <body>
        <a href="#list-event" class="skip" tabindex="-1"><g:message code="default.link.skip.label" default="Skip to content&hellip;"/></a>
            <div id="list-event" class="content scaffold-list" role="main">
                <h1><g:message code="default.list.label" args="[entityName]" /></h1>
            <g:if test="${flash.message}">
                <div class="message" role="status">${flash.message}</div>
            </g:if>
            <table>
                <thead>
                    <tr>

                        <th><g:message code="event.serial.label" default="Serial" /></th>

                        <th><g:message code="event.kind.label" default="Kind" /></th>

                            <g:sortableColumn property="name" title="${message(code: 'event.name.label', default: 'Name')}" />

                            <g:sortableColumn property="audience" title="${message(code: 'event.audience.label', default: 'Audience')}" />

                            <g:sortableColumn property="dateStart" title="${message(code: 'event.dateStart.label', default: 'Date Start')}" />

                            <g:sortableColumn property="dateEnd" title="${message(code: 'event.dateEnd.label', default: 'Date End')}" />

                        <th>已報/可報/候補名額</th>

                        <th>報名/報到管理</th>
                        
                    </tr>
                </thead>
                <tbody>
                    <g:each in="${eventInstanceList}" status="i" var="eventInstance">
                        <tr class="${(i % 2) == 0 ? 'even' : 'odd'}">

                            <td>${fieldValue(bean: eventInstance, field: "serial")}</td>

                            <td>${fieldValue(bean: eventInstance, field: "kind")}</td>

                            <td>${fieldValue(bean: eventInstance, field: "name")}</td>

                            <td>${fieldValue(bean: eventInstance, field: "audience")}</td>

                            <td><g:formatDate date="${eventInstance.dateStart}" /></td>

                            <td><g:formatDate date="${eventInstance.dateEnd}" /></td>

                            <g:if test="${session.accountId == '1'}">
                                <td><g:link controller="register" action="calcRegisterQty" params="[eventId:"${eventInstance.id}", fromAction:"${actionName}"]">${eventInstance.registerQty}/${fieldValue(bean: eventInstance, field: "capacityQty")}/${fieldValue(bean: eventInstance, field: "standbyQty")}</g:link></td>
                            </g:if>
                            <g:else>
                                <td>${fieldValue(bean: eventInstance, field: "registerQty")}/${fieldValue(bean: eventInstance, field: "capacityQty")}/${fieldValue(bean: eventInstance, field: "standbyQty")}</td>                                
                            </g:else>

                            <td><g:link controller="register" action="list" params="[eventId:"${eventInstance.id}"]">報名</g:link> / <g:link controller="register" action="attend" params="[eventId:"${eventInstance.id}"]">報到</g:link></td>
                            
                        </tr>
                    </g:each>
                </tbody>
            </table>
            <div class="pagination">
                <m:paginate total="${eventInstanceTotal}" />
            </div>
        </div>
    </body>
</html>
